﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;

namespace Pharmacy.Logging
{
    public class Logging
    {
        /// <summary>
        /// Exception handling policy: "General".
        /// </summary>
        public const string EX_POLICY_GENERAL = "General";

        /// <summary>
        /// Exception handling policy: "Unhandled".
        /// </summary>
        public const string EX_POLICY_UNHANDLED = "Unhandled";

        /// <summary>
        /// Log category: "General"
        /// </summary>
        public const string LOG_CAT_GENERAL = "General";

        /// <summary>
        ///  An instance LogWriter to write log messages based on a given configuration. Messages are routed based on category.
        /// </summary>
        /// <remarks>
        /// To write log messages to the default configuration, use the Microsoft.Practices.EnterpriseLibrary.Logging.Logger
        /// facade. Only create an instance of a LogWriter if you need to write log messages
        /// using a custom configuration.
        /// The LogWriter works as an entry point to the System.Diagnostics trace listeners.
        /// It will trace the Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry
        /// through the Microsoft.Practices.EnterpriseLibrary.Logging.TraceListenerss
        /// associated with the Microsoft.Practices.EnterpriseLibrary.Logging.LogSources
        /// for all the matching categories in the elements of the Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry.Categories
        /// property of the log entry. If the "all events" special log source is configured,
        /// the log entry will be traced through the log source regardles of other categories
        /// that might have matched.  If the "all events" special log source is not configured
        /// and the "unprocessed categories" special log source is configured, and the
        /// category specified in the logEntry being logged is not defined, then the
        /// logEntry will be logged to the "unprocessed categories" special log source.
        /// If both the "all events" and "unprocessed categories" special log sources
        /// are not configured and the property LogWarningsWhenNoCategoriesMatch is set
        /// to true, then the logEntry is logged to the "logging errors and warnings"
        /// special log source.
        /// </remarks>
        public static readonly LogWriter LogWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

        /// <summary>
        /// An instance of a performance tracing class to log method entry/exit and duration.
        /// </summary>
        public static readonly TraceManager TraceMgr = EnterpriseLibraryContainer.Current.GetInstance<TraceManager>();

        /// <summary>
        /// Instances of Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager
        /// can be used to replace references to the static Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy
        /// facade.
        /// </summary>
        public static readonly ExceptionManager ExceptionMgr = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
    }
}
